home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / optivc32 / matlib.h < prev    next >
C/C++ Source or Header  |  1999-03-06  |  5KB  |  125 lines

  1. /*  MatLib.h
  2.  
  3.   two-dimensional-matrix management functions.
  4.  
  5.   Copyright (c) 1996-1999 by Martin Sander
  6.   All Rights Reserved.
  7. */
  8.  
  9. #ifndef __MATLIB_H
  10. #define __MATLIB_H
  11.  
  12. #define C_MATRIX 1   /* does your compiler follow the C convention
  13.                         of element ordering?
  14.                         if not, change this line into
  15.                         "   #define C_MATRIX 0   "!
  16.                      */
  17.  
  18. #ifndef __VECLIB_H
  19.     #include <VecLib.h>
  20. #endif
  21. #if defined( V_HUGE )
  22.      #define   V_DATAPTR  huge
  23. #else
  24.      #define   V_DATAPTR
  25. #endif
  26.  
  27. /**********************************************************************
  28.  *   The following definitions ensure compatibility between           *
  29.  *   dynamically allocated matrices (e.g., by MF_matrix) and          *
  30.  *   static ones (declared, e.g., by float MA[20][20];                *
  31.  *   for details see MFstd.h                                          */
  32.  
  33. typedef   char   V_DATAPTR  *           biPMatrix;
  34. typedef   short  V_DATAPTR  *           siPMatrix;
  35. typedef   int    V_DATAPTR  *           iPMatrix;
  36. typedef   long   V_DATAPTR  *           liPMatrix;
  37. typedef   quad   V_DATAPTR  *           qiPMatrix;
  38. typedef   unsigned char  V_DATAPTR *    ubPMatrix;
  39. typedef   unsigned short V_DATAPTR *    usPMatrix;
  40. typedef   unsigned int   V_DATAPTR *    uPMatrix;
  41. typedef   unsigned long  V_DATAPTR *    ulPMatrix;
  42. typedef   ui        V_DATAPTR   *       uiPMatrix;   
  43. typedef   float     V_DATAPTR   *       fPMatrix;
  44. typedef   double    V_DATAPTR   *       dPMatrix;
  45. typedef   extended  V_DATAPTR   *       ePMatrix;
  46. typedef   fComplex  V_DATAPTR   *       cfPMatrix;
  47. typedef   dComplex  V_DATAPTR   *       cdPMatrix;
  48. typedef   eComplex  V_DATAPTR   *       cePMatrix;
  49.  
  50. typedef   biPMatrix  *        biMatrix;
  51. typedef   ubPMatrix  *        ubMatrix;
  52. typedef   siPMatrix  *        siMatrix;
  53. typedef   usPMatrix  *        usMatrix;
  54. typedef   iPMatrix   *        iMatrix;
  55. typedef   uPMatrix   *        uMatrix;
  56. typedef   liPMatrix  *        liMatrix;
  57. typedef   ulPMatrix  *        ulMatrix;
  58. typedef   uiPMatrix  *        uiMatrix;
  59. typedef   qiPMatrix  *        qiMatrix;
  60. typedef   fPMatrix   *        fMatrix;
  61. typedef   dPMatrix   *        dMatrix;
  62. typedef   ePMatrix   *        eMatrix;
  63. typedef   cfPMatrix  *        cfMatrix;
  64. typedef   cdPMatrix  *        cdMatrix;
  65. typedef   cePMatrix  *        ceMatrix;
  66.  
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70.  
  71. /*************   Dynamic Generation of Matrices   ************************
  72.           defined here only for the integer data types;
  73.           for the floating-point types, see <MFstd.h> etc.
  74.           For integer matrices, these are the only functions
  75.           so far included in VectorLib.                                  */
  76.  
  77. biMatrix __vf  MBI_matrix(  unsigned ht, unsigned len );
  78. biMatrix __vf  MBI_matrix0( unsigned ht, unsigned len );
  79. ubMatrix __vf  MUB_matrix(  unsigned ht, unsigned len );
  80. ubMatrix __vf  MUB_matrix0( unsigned ht, unsigned len );
  81. siMatrix __vf  MSI_matrix(  unsigned ht, unsigned len );
  82. siMatrix __vf  MSI_matrix0( unsigned ht, unsigned len );
  83. usMatrix __vf  MUS_matrix(  unsigned ht, unsigned len );
  84. usMatrix __vf  MUS_matrix0( unsigned ht, unsigned len );
  85. iMatrix  __vf  MI_matrix(   unsigned ht, unsigned len );
  86. iMatrix  __vf  MI_matrix0(  unsigned ht, unsigned len );
  87. uMatrix  __vf  MU_matrix(   unsigned ht, unsigned len );
  88. uMatrix  __vf  MU_matrix0(  unsigned ht, unsigned len );
  89. liMatrix __vf  MLI_matrix(  unsigned ht, unsigned len );
  90. liMatrix __vf  MLI_matrix0( unsigned ht, unsigned len );
  91. ulMatrix __vf  MUL_matrix(  unsigned ht, unsigned len );
  92. ulMatrix __vf  MUL_matrix0( unsigned ht, unsigned len );
  93. qiMatrix __vf  MQI_matrix(  unsigned ht, unsigned len );
  94. qiMatrix __vf  MQI_matrix0( unsigned ht, unsigned len );
  95. #if defined( V_HUGE )
  96.    #define MUI_matrix  MUL_matrix
  97.    #define MUI_matrix0 MUL_matrix0
  98. #else
  99.    #define MUI_matrix  MU_matrix
  100.    #define MUI_matrix0 MU_matrix0
  101. #endif
  102.     /*  notice that, in the memory model HUGE,
  103.         neither len nor ht may exceed 32767/sizeof(type)            */
  104.  
  105.  /* the following functions allocate pointer vectors and pointer matrices: */ 
  106. #if defined __COMPACT__ || defined __LARGE__ || defined __HUGE__
  107.     #define VUP_vector  VUL_vector  /* pointer to vector */
  108.     #define MUP_matrix  MUL_matrix  /* pointer to matrix */
  109. #else
  110.     #define VUP_vector  VU_vector
  111.     #define MUP_matrix  MU_matrix
  112. #endif
  113.  
  114. /*   de-allocation of matrices (common to all data types): */
  115. void    __vf  Mfree( void **M );
  116. #define M_free( M ) Mfree( (void **)(M) )
  117. void    __vf  M_nfree( unsigned n, ... );
  118.  
  119. #ifdef __cplusplus
  120. }  // end of extern "C"
  121. #endif
  122.  
  123. #undef V_DATAPTR
  124. #endif   /* __MATLIB_H  */
  125.